package com.yelobblog.yelobblog.common.exception;

import com.yelobblog.yelobblog.common.untils.Response;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

@ControllerAdvice
public class BlogExceptionHandler {
    @ExceptionHandler(value =ApiException.class)
    public ResponseEntity<Response<?>> exceptionHandler(ApiException e){
        Response<?> response = Response.fail(e.getErrorCode(),e.getErrorMsg());
       return new ResponseEntity<>(response, HttpStatus.valueOf(200));
    }

//    @ExceptionHandler(value =Exception.class)
//    public ResponseEntity<Response<?>> exceptionHandler(Exception e){
//        Response<?> response = Response.fail(ErrorEnum.SYSTEM_ERROR.getErrorCode(),ErrorEnum.SYSTEM_ERROR.getErrorMsg());
//        return new ResponseEntity<>(response, HttpStatus.valueOf(200));
//    }
}
